﻿namespace MultiFileUpload.Models
{
    using System.Web.Mvc;

    /// <summary>
    /// File upload result wrapper.
    /// </summary>
    public class FileUploadJsonResult : JsonResult
    {
        /// <summary>
        /// Enables processing of the result of an action method by a custom type that inherits from <see cref="T:System.Web.Mvc.ActionResult"/>.
        /// </summary>
        /// <param name="context">The context within which the result is executed.</param>
        public override void ExecuteResult(ControllerContext context)
        {
            // Для удобства отладки javascript и JSON-ответов jQuery.Form плагин
            // позволяет оборачивать ответ в тег <c>textarea</c>.
            ContentType = "text/html";
            context.HttpContext.Response.Write("<textarea>");
            base.ExecuteResult(context);
            context.HttpContext.Response.Write("</textarea>");
        }
    }
}
